#!/usr/bin/python
# -*- encoding: utf-8 -*-
'''
@File    :   1.py
@Time    :   2020/05/03 20:27:57
@Author  :   Malygos_l 
@Version :   1.0    
@Contact :   751756061@qq.com
@WebSite :   www.gitee.com/malygos_l
'''
#定义一个10个元素的列表，通过列表自带的函数，实现元素在尾部插入和头部插入并记录程序运行的时间；用deque来实现，同样记录程序所耗费的时间；输出这2个时间的差值；
# 提示：列表原生的函数实现头部插入数据：list.insert(0, v)；list.append（2）)
# Start typing your code from here

from collections import deque
from datetime import datetime,timedelta

list1 = [0,0,0,0,0,0,0,0,0,0]
list2 = deque([0,0,0,0,0,0,0,0,0,0])

# 自带函数
start1 = datetime.now()
for i in range(10000):
    list1.insert(0,-1*i)
    list1.append(i)
end1 = datetime.now()
a = (end1-start1).microseconds

# deque
start2 = datetime.now()
for i in range(10000):
    list2.appendleft(-1*i)
    list2.append(i)
end2 = datetime.now()
b = (end2-start2).microseconds

# 输出差值
print(((end1-start1)-(end2-start2)).microseconds)